package com.example.leetcode;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class ReadWriteLockTest {


    private List<Integer> list = new ArrayList<>();

    private ReadWriteLock lock = new ReentrantReadWriteLock();


    private Lock readLock = lock.readLock();


    private Lock writeLock = lock.writeLock();


    public int get(){
        readLock.lock();
        try {
            writeLock.lock();
            readLock.unlock();
        }finally {
            writeLock.unlock();
        }
        return 1;
    }
}
